package com.tiger.weixin.config;

import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpRequest;
import org.springframework.http.client.ClientHttpRequestExecution;
import org.springframework.http.client.ClientHttpRequestInterceptor;
import org.springframework.http.client.ClientHttpResponse;

import java.io.IOException;
import java.net.URI;

/**
 * @Author: spzhang
 * @Date: Created in 13:46 2023/2/20
 * @Description:
 * @Version:
 */
@Slf4j
public class WeixinRestTemplateInterceptor implements ClientHttpRequestInterceptor {
    @Override
    public ClientHttpResponse intercept(HttpRequest request, byte[] body, ClientHttpRequestExecution execution) throws IOException {
        log.debug("拦截微信请求信息");
        URI uri = request.getURI();
        log.debug("uri={}", uri);
        log.debug("body={}", new String(body));
        return execution.execute(request, body);
    }
}
